const express = require('express');
const { getOpenid, wxLogin, bindPhoneNumber } = require('../controllers/clientController');
const { authenticateUser } = require('../middleware/auth');

const router = express.Router();

/**
 * @route   POST /api/auth/get-openid
 * @desc    通过code获取用户openid
 * @access  Public
 * @body    { code: string }
 * @returns { success: boolean, data: { openid: string, session_key: string } }
 */
router.post('/get-openid', getOpenid);

/**
 * @route   POST /api/auth/wx-login
 * @desc    微信小程序登录
 * @access  Public
 * @body    { code: string, userInfo?: object }
 * @returns { success: boolean, data: { token: string, userInfo: object } }
 */
router.post('/wx-login', wxLogin);

/**
 * @route   POST /api/auth/bind-phone
 * @desc    绑定用户手机号
 * @access  Private (需要登录)
 * @body    { code: string }
 * @returns { success: boolean, data: { userInfo: object } }
 */
router.post('/bind-phone', authenticateUser, bindPhoneNumber);

module.exports = router;